import javax.swing.JOptionPane;
import java.util.Random;

public class Challenge7
{
	
	public static void main(String[] args)
	{
		Random randomNumberGenerator = new Random();
		String guess = "";
		String choice = "";
		int number1 = randomNumberGenerator.nextInt(100);
		int number2 = randomNumberGenerator.nextInt(100);
		while (!guess.equals("q"))
		{
			
			choice = JOptionPane.showInputDialog("Choose your operation: \n / \n * \n + \n -");
			switch (choice)
			{
				case "*":
					guess = JOptionPane.showInputDialog("Answer this problem or type q to quit: \n " + number1 + "*" + number2 + "=");
					JOptionPane.showInputDialog("You chose *");
					if (guess.equals("q"))
					{
						JOptionPane.showMessageDialog(null, "You quit.");
					}
					else
					{
						int guessint = Integer.parseInt(guess);
						if (guessint == (number1 + number2))
						{
							JOptionPane.showMessageDialog(null, "It's right!");
						}
						else
						{
							JOptionPane.showMessageDialog(null, "It's wrong! \n The correct answer was: " + (number1 + number2));
						}}
						break;
						case "+":
							guess = JOptionPane.showInputDialog("Answer this problem or type q to quit: \n " + number1 + "*" + number2 + "=");
							JOptionPane.showInputDialog("You chose *");
							if (guess.equals("q"))
							{
								JOptionPane.showMessageDialog(null, "You quit.");
							}
							else
							{
								int guessint = Integer.parseInt(guess);
								if (guessint == (number1 + number2))
								{
									JOptionPane.showMessageDialog(null, "It's right!");
								}
								else
								{
									JOptionPane.showMessageDialog(null, "It's wrong! \n The correct answer was: " + (number1 + number2));
								}
								break;
					
			}
			
			guess = JOptionPane.showInputDialog("Answer this problem or type q to quit: \n " + number1 + "+" + number2 + "=");
			if (guess.equals("q"))
			{
				JOptionPane.showMessageDialog(null, "You quit.");
			}
			else
			{
				int guessint = Integer.parseInt(guess);
				if (guessint == (number1 + number2))
				{
					JOptionPane.showMessageDialog(null, "It's right!");
				}
				else
				{
					JOptionPane.showMessageDialog(null, "It's wrong! \n The correct answer was: " + (number1 + number2));
				}
			}
			
		}
	}
}}
